package com.distribute.framework.model;

import com.distribute.framework.core.web.helper.Utils;
import java.lang.reflect.Field;
import java.util.Date; 
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;

import javax.annotation.Resource;

import com.distribute.framework.core.web.util.Page;
import com.distribute.framework.core.lang.*; 
import com.distribute.framework.core.web.helper.WebHelper.LzMap;
import com.distribute.framework.core.util.Function;
import com.distribute.framework.core.util.IbatisMap;
import com.distribute.framework.config.*;
import com.distribute.framework.plugin.*;

@namespace("api/api")
public @caption("API接口") @database(DatabaseNames.distribute_sys) @source("distribute_sys") @table("srv_api") class SrvApi implements java.io.Serializable
{
	private static final long serialVersionUID = 1l;
	private @caption("编号") @column("sa_id")    @primary  @notnull  @note("  ") Long saId;// 主键 非空     
	private @caption("API名称") @column("sa_name")     @notnull  @note("  中文描述") String saName;// 非空  中文描述   
	private @caption("名称空间") @column("sa_namespace")     @notnull  @note("  格式如:com.xxxx.xxx") String saNamespace;// 非空  格式如:com.xxxx.xxx   
	private @caption("接口分类") @column("sa_type")     @notnull  @relate("$saType") @RelateClass(SrvApiType.class)  @note("  ") Long saType;// 非空     
 	private transient SrvApiType $saType;//关联对象[API分类]
	private @caption("版本号") @column("sa_version")     @notnull  @note(" 1:V1 2:V2 3:V3  ") Short saVersion;// 非空 1:V1 2:V2 3:V3     
	private @caption("是否开放") @column("sa_open")     @notnull  @note(" 1:开放 0:非开放  ") Short saOpen;// 非空 1:开放 0:非开放     
	private @caption("需要用户授权") @column("sa_oauth")     @notnull  @note(" 0:无需授权 1:需要授权  ") Short saOauth;// 非空 0:无需授权 1:需要授权     
	private @caption("接口说明") @column("sa_descript")      @note("  ") String saDescript;//     
	private @caption("接口类名") @column("sa_class") @like  @hidden   @notnull  @note("  脚本代码为java代码,参数结构中定义的变量名可直接使用,有错误返回错误代码，没错误无需返回") String saClass;// 非空  脚本代码为java代码,参数结构中定义的变量名可直接使用,有错误返回错误代码，没错误无需返回   
	private @caption("数据方向") @column("sa_dir")     @notnull  @note(" 0:请求 1:推送  ") Short saDir;// 非空 0:请求 1:推送     
	private @caption("函数名称") @column("sa_method")     @notnull  @note("  ") String saMethod;// 非空     
	private @caption("记录日志") @column("sa_log")      @note(" 0:否 1:是  ") Short saLog;// 0:否 1:是     
	private @caption("参数结构") @column("sa_params") @like  @hidden    @note("  ") String saParams;//     
	private @caption("返回结构") @column("sa_return_struct") @like  @hidden   @notnull  @note("  ") String saReturnStruct;// 非空     
	private @caption("错误代码") @column("sa_error") @like  @hidden    @note("  ") String saError;//     
	private @caption("修改时间") @column("sa_update_time")     @notnull  @note("  ") Date saUpdateTime;// 非空     
	private @caption("添加时间") @column("sa_add_time")     @notnull  @note("  ") Date saAddTime;// 非空     
	private @caption("状态") @column("sa_status")     @notnull  @note(" 0:测试中 1:正常 2:禁用  ") Short saStatus;// 非空 0:测试中 1:正常 2:禁用     
	 
	//默认构造函数
	public SrvApi(){ 
	
	}
	
	//主键构造函数
	public SrvApi(Long id){
		this.saId = id;
	}
	
	/**所有字段构造函数 
	 SrvApi(
	 	Utils.getString("saName")//API名称 [非空]
	 	,Utils.getString("saNamespace")//名称空间 [非空]
	 	,Utils.getLong("saType")//接口分类 [非空]
	 	,Utils.getShort("saVersion")//版本号 [非空]
	 	,Utils.getShort("saOpen")//是否开放 [非空]
	 	,Utils.getShort("saOauth")//需要用户授权 [非空]
	 	,Utils.getString("saDescript")//接口说明
	 	,Utils.getString("saClass")//接口类名 [非空]
	 	,Utils.getShort("saDir")//数据方向 [非空]
	 	,Utils.getString("saMethod")//函数名称 [非空]
	 	,Utils.getShort("saLog")//记录日志
	 	,Utils.getString("saParams")//参数结构
	 	,Utils.getString("saReturnStruct")//返回结构 [非空]
	 	,Utils.getString("saError")//错误代码
	 	,Utils.getDate("saUpdateTime")//修改时间 [非空]
	 	,Utils.getDate("saAddTime")//添加时间 [非空]
	 	,Utils.getShort("saStatus")//状态 [非空]
	 )
	**/
	public SrvApi(String saName,String saNamespace,Long saType,Short saVersion,Short saOpen,Short saOauth,String saDescript,String saClass,Short saDir,String saMethod,Short saLog,String saParams,String saReturnStruct,String saError,Date saUpdateTime,Date saAddTime,Short saStatus){
		this.saName=saName;
		this.saNamespace=saNamespace;
		this.saType=saType;
		this.saVersion=saVersion;
		this.saOpen=saOpen;
		this.saOauth=saOauth;
		this.saDescript=saDescript;
		this.saClass=saClass;
		this.saDir=saDir;
		this.saMethod=saMethod;
		this.saLog=saLog;
		this.saParams=saParams;
		this.saReturnStruct=saReturnStruct;
		this.saError=saError;
		this.saUpdateTime=saUpdateTime;
		this.saAddTime=saAddTime;
		this.saStatus=saStatus;
	}
	
	//设置非空字段
	public SrvApi setNotNull(String saName,String saNamespace,Long saType,Short saVersion,Short saOpen,Short saOauth,String saClass,Short saDir,String saMethod,String saReturnStruct,Date saUpdateTime,Date saAddTime,Short saStatus){
		this.saName=saName;
		this.saNamespace=saNamespace;
		this.saType=saType;
		this.saVersion=saVersion;
		this.saOpen=saOpen;
		this.saOauth=saOauth;
		this.saClass=saClass;
		this.saDir=saDir;
		this.saMethod=saMethod;
		this.saReturnStruct=saReturnStruct;
		this.saUpdateTime=saUpdateTime;
		this.saAddTime=saAddTime;
		this.saStatus=saStatus;
		return this;
	}
	/** 编号 [非空]       **/
	public SrvApi saId(Long saId){
		this.saId = saId;
		this.setSeted(F.saId);
		return this;
	}
	/** API名称 [非空]    中文描述   **/
	public SrvApi saName(String saName){
		this.saName = saName;
		this.setSeted(F.saName);
		return this;
	}
	/** 名称空间 [非空]    格式如:com.xxxx.xxx   **/
	public SrvApi saNamespace(String saNamespace){
		this.saNamespace = saNamespace;
		this.setSeted(F.saNamespace);
		return this;
	}
	/** 接口分类 [非空] [SrvApiType]      **/
	public SrvApi saType(Long saType){
		this.saType = saType;
		this.setSeted(F.saType);
		return this;
	}
	/** 版本号 [非空]   1:V1 2:V2 3:V3     **/
	public SrvApi saVersion(Short saVersion){
		this.saVersion = saVersion;
		this.setSeted(F.saVersion);
		return this;
	}
	/** 是否开放 [非空]   1:开放 0:非开放     **/
	public SrvApi saOpen(Short saOpen){
		this.saOpen = saOpen;
		this.setSeted(F.saOpen);
		return this;
	}
	/** 需要用户授权 [非空]   0:无需授权 1:需要授权     **/
	public SrvApi saOauth(Short saOauth){
		this.saOauth = saOauth;
		this.setSeted(F.saOauth);
		return this;
	}
	/** 接口说明        **/
	public SrvApi saDescript(String saDescript){
		this.saDescript = saDescript;
		this.setSeted(F.saDescript);
		return this;
	}
	/** 接口类名 [非空]    脚本代码为java代码,参数结构中定义的变量名可直接使用,有错误返回错误代码，没错误无需返回   **/
	public SrvApi saClass(String saClass){
		this.saClass = saClass;
		this.setSeted(F.saClass);
		return this;
	}
	/** 数据方向 [非空]   0:请求 1:推送     **/
	public SrvApi saDir(Short saDir){
		this.saDir = saDir;
		this.setSeted(F.saDir);
		return this;
	}
	/** 函数名称 [非空]       **/
	public SrvApi saMethod(String saMethod){
		this.saMethod = saMethod;
		this.setSeted(F.saMethod);
		return this;
	}
	/** 记录日志    0:否 1:是     **/
	public SrvApi saLog(Short saLog){
		this.saLog = saLog;
		this.setSeted(F.saLog);
		return this;
	}
	/** 参数结构        **/
	public SrvApi saParams(String saParams){
		this.saParams = saParams;
		this.setSeted(F.saParams);
		return this;
	}
	/** 返回结构 [非空]       **/
	public SrvApi saReturnStruct(String saReturnStruct){
		this.saReturnStruct = saReturnStruct;
		this.setSeted(F.saReturnStruct);
		return this;
	}
	/** 错误代码        **/
	public SrvApi saError(String saError){
		this.saError = saError;
		this.setSeted(F.saError);
		return this;
	}
	/** 修改时间 [非空]       **/
	public SrvApi saUpdateTime(Date saUpdateTime){
		this.saUpdateTime = saUpdateTime;
		this.setSeted(F.saUpdateTime);
		return this;
	}
	/** 添加时间 [非空]       **/
	public SrvApi saAddTime(Date saAddTime){
		this.saAddTime = saAddTime;
		this.setSeted(F.saAddTime);
		return this;
	}
	/** 状态 [非空]   0:测试中 1:正常 2:禁用     **/
	public SrvApi saStatus(Short saStatus){
		this.saStatus = saStatus;
		this.setSeted(F.saStatus);
		return this;
	}
	
	
	/**
	* 克隆对象
	**/
	public SrvApi clone(){
		SrvApi clone = new SrvApi();
		clone.saName=this.saName;
		clone.saNamespace=this.saNamespace;
		clone.saType=this.saType;
		clone.saVersion=this.saVersion;
		clone.saOpen=this.saOpen;
		clone.saOauth=this.saOauth;
		clone.saDescript=this.saDescript;
		clone.saClass=this.saClass;
		clone.saDir=this.saDir;
		clone.saMethod=this.saMethod;
		clone.saLog=this.saLog;
		clone.saParams=this.saParams;
		clone.saReturnStruct=this.saReturnStruct;
		clone.saError=this.saError;
		clone.saUpdateTime=this.saUpdateTime;
		clone.saAddTime=this.saAddTime;
		clone.saStatus=this.saStatus;
		return clone;
	}
	/**
	* 清除缓存
	**/
	public void clear(){
		Cache.clearObject(SrvApi.M.class);
		Cache.clearValue(SrvApi.M.class);
		Cache.deleteObject(SrvApi.class, this.getId());
	}
	
	/**
	* 清除缓存
	**/
	public static void clear(Long id){
		Cache.clearObject(SrvApi.M.class);
		Cache.clearValue(SrvApi.M.class);
		Cache.deleteObject(SrvApi.class, id);
	}
	
	
	/**
	 * 根据ID取API接口
	 * @param id
	 * @return
	 */
	public static @api SrvApi get(Long id){		
		return getSrvApiById(id);
	}
	/**
	 * 设置ID
	 * @param id
	 * @return
	 */
	public void setId(Long id){		
		this.saId = id;
	}
	
	/**
	 * 获取所有API接口
	 * @return
	 */
	public static @api List<SrvApi> list(Map params,Integer size){
		return getSrvApiList(params,size);
	}
	/**
	 * 获取API接口分页
	 * @return
	 */
	public static @api Page<SrvApi> page(Integer page,Integer size,Map params){
		return getSrvApiPage(page, size , params);
	}
	
	
	/**
	 * 根据查询条件取API接口
	 * @param params
	 * @return
	 */
	public static @api SrvApi Get(Map params){
		return getSrvApi(params);
	}
	/**
	 * 获取API接口数
	 * @return
	 */
	public static @api Long count(Map params){
		return getSrvApiCount(params);
	}
	/**
	 * 获取API接口数
	 * @return
	 */
	public static @api <T> T eval(String eval,Map params){
		return getSrvApiEval(eval,params);
	}
	/**
	 * 获取API接口图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey){
		return getSrvApiStats(params,sumKey,groupKey,-1);
	}
	/**
	 * 获取API接口图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey,int dateType){
		return getSrvApiStats(params,sumKey,groupKey,dateType);
	}
	
	/**
	 * 根据ID取API接口
	 * @param id
	 * @return
	 */
	public static @api SrvApi getSrvApiById(Long id){		
		return getSrvApiDao().getSrvApiById(id);
	}
	/**
	 * 获取id
	 * @return
	 */
	public Long getId(){
		return this.saId;
	}
	
	
	/**
	 * 根据ID取API接口的标识键值
	 * @param id
	 * @return
	 */
	public static @api String getKeyValue(Object key){
		Long id = Utils.parseLong(key);	
		if(id==null || id.longValue()==0 ){
			return null;
		}
		String value = null;
		value = Cache.getValue(SrvApi.class, id);
		if(value==null){
			SrvApi srvApi = get(id);
			if(srvApi!=null){
				String strValue = srvApi.getSaName$();
				if(!"SaName".equals("SaName"))
					strValue+="("+srvApi.getSaName$()+")";
				if(!"SaName".equals("SaNamespace"))
					strValue+="("+srvApi.getSaNamespace$()+")";
				Cache.setValue(SrvApi.class, id ,strValue);
				value = strValue;
			}else{
				Cache.setValue(SrvApi.class, id ,"{"+id+"}",30);
				value = "{"+id+"}";
			}
		}
		/************LAZY3Q_ID_KEYVALUE************/
		/************LAZY3Q_ID_KEYVALUE************/
		return value;
	}	
	
	
	/**
	 * 获取当前对象的键值
	 * @return
	 */
	public String getKeyValue(){
		/************LAZY3Q_CODE_KEYVALUE************/
		/************LAZY3Q_CODE_KEYVALUE************/
		String keyValue = this.getSaName$();
		if(!"SaName".equals("SaName"))
			keyValue+="("+this.getSaName$()+")";
		if(!"SaName".equals("SaNamespace"))
			keyValue+="("+this.getSaNamespace$()+")";
		return keyValue;
	}
	
	
	/**
	 * 根据关键字精确查询API接口对象
	 * @return
	 */
	public static @api SrvApi find(String key){
		if(Utils.empty(key))return null;
		Map params = new HashMap();
		if(key.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
			params.put("saId", key.toLowerCase().replaceFirst("id:", ""));					
		else{//按标识查询，精确查询
			String strDefinex = "";
			strDefinex+=" or sa_name = '"+key.replaceAll("'", "''")+"'";
			strDefinex+=" or sa_namespace = '"+key.replaceAll("'", "''")+"'";
			strDefinex="(2=1 "+strDefinex+")";
			params.put("definex",strDefinex);
		}
		/************LAZY3Q_CODE_FIND************/
		/************LAZY3Q_CODE_FIND************/
		return SrvApi.getSrvApi(params);
	}
	
	
	/**
	 * 根据关键字查询API接口
	 * @return
	 */
	public static @api List<Map> query(String key,int size,Map params,Boolean bObject){
		if(Utils.empty((String)params.get("asc")) && Utils.empty((String)params.get("desc")))//如果未传入排序字段
			params.put("desc","sa_id");//那么，默认以主键降序，传给Dao层
		String strTerm=key;		
		if(!Utils.empty(strTerm)){
			if(strTerm.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
				params.put("saId", strTerm.toLowerCase().replaceFirst("id:", ""));					
			else//按标识查询，模糊查询请带%
			{
				String strDefinex = "";
				strDefinex+=" or sa_name like '%"+strTerm.replaceAll("'", "''")+"%'";
				strDefinex+=" or sa_namespace like '%"+strTerm.replaceAll("'", "''")+"%'";
				strDefinex="(2=1 "+strDefinex+")";
				params.put("definex",strDefinex);
			}
		}
		/************LAZY3Q_CODE_QUERY************/
		/************LAZY3Q_CODE_QUERY************/
			
		List<SrvApi> list = page(0,size,params).getResult();
		
		/**
		* OK!取到数据拼成放入Map中，[{value,text,object:{...}},...]
		* value:数据ID，text:数据标识,object,整个对象
		**/
		List<Map> result = new java.util.ArrayList();
		for(SrvApi srvApi:list){
			Map map = new HashMap();
			map.put("key",srvApi.getSaId().toString());
			map.put("value", Utils.js(srvApi.getKeyValue()));
			if(bObject==true)
				map.put("object",srvApi);
			result.add(map);
		}
		/************LAZY3Q_AFTER_QUERY************/
		/************LAZY3Q_AFTER_QUERY************/
		
		return result;
	}
	
	
	
	/**
	 * 获取所有API接口
	 * @return
	 */
	public static @api List<SrvApi> getSrvApiList(Map params,Integer size){
		return getSrvApiDao().getSrvApiList(params,0,size);
	}
	
	/**
	 * 获取API接口分页
	 * @return
	 */
	public static @api Page<SrvApi> getSrvApiPage(Integer page,Integer size,Map params){
		if(page==null)page=0;
		if(size==null)size=20;
		return getSrvApiDao().getSrvApiPage(page, size , params);
	}
	
	/**
	 * 根据查询条件取API接口
	 * @param params
	 * @return
	 */
	public static @api SrvApi getSrvApi(Map params){
		return getSrvApiDao().getSrvApi(params);
	}
	
	/**
	 * 保存一个API接口
	 * @param srvApi
	 * @return
	 */
	public static @api SrvApi saveSrvApi(SrvApi srvApi){
		return getSrvApiDao().saveSrvApi(srvApi);
	}
	
	/**
	 * 根据条件更新API接口
	 * @param values
	 * @param params
	 */
	public static @api int updateSrvApiByConfirm(Map values, Map params){
		return getSrvApiDao().updateSrvApiByConfirm(values,params);
	}
	
	/**
	 * 修改一个API接口
	 * @param srvApi
	 * @return
	 */
	public static @api int updateSrvApi(SrvApi srvApi){
		return getSrvApiDao().updateSrvApi(srvApi);
	}
	
	/**
	 * 更新API接口非空字段
	 * @param srvApi
	 */
	public static @api int updateSrvApi$NotNull(SrvApi srvApi){
		return getSrvApiDao().updateSrvApi$NotNull(srvApi);
	}
	
	/**
	 * 获取API接口数
	 * @return
	 */
	public static @api Long getSrvApiCount(Map params){
		return getSrvApiDao().getSrvApiCount(params);
	}
		
		
	/**
	 * 获取API接口自定义求和表达式,比如求和:eval="sum(id)"
	 * @return
	 */	
	public static @api <T> T getSrvApiEval(String eval,Map params){
		return getSrvApiDao().getSrvApiEval(eval,params);
	}
	/**
	 * 获取API接口图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> getSrvApiStats(Map params,C sumKey,C groupKey,int dateType){
		//TODO:图表统计功能未实现
		
		Map<String,Object> groups=new HashMap();//要分组的字段
		Map<String,Object> sums=new HashMap();//要统计的字段
		
		String[][] dateFormats=new String[][]{
				null,
				new String[]{"%Y","yyyy年","Y"},
				new String[]{"%Y-%m","yyyy年MM月","M"},
				new String[]{"%Y%U","yyyy年第ww周","W"},
				new String[]{"%Y-%m-%d","yyyy年MM月dd日","D"},
				new String[]{"%Y-%m-%d %H","yyyy年MM月dd日 HH点","H"},
				new String[]{"%m","MM月"},
				new String[]{"%d","dd号"},
				new String[]{"%H","HH点"} 
		};
		
		//获取要分组的字段，放入Map中
		if(dateType>0){
			groups.put(groupKey.toString(),"DATE_FORMAT({key},'"+dateFormats[dateType][0]+"')");
		}else{
			groups.put(groupKey.toString(),"{key}");
		}
		if(dateType<6 && dateType>0){ 
			params.put("asc", groupKey.toString()); 
			if(params.get(groupKey.name()+"Start")==null){
				params.put(groupKey.name()+"Start", Utils.date(new Date(), -24, dateFormats[dateType][2]));
			}
		}
		
		
		//获取要统计的字段，放入Map中
		if(sumKey.toString().equals("count")){
			sums.put(sumKey.toString(),"count(*)");
		}else{
			sums.put(sumKey.toString(),"sum({key})");
		}
		
		List<Map> list = getSrvApiDao().getSrvApiStats(params,groups,sums);
		
		List<Map> result = new ArrayList();
		for(Map m:list){
			Map map = new HashMap();
			Object value = m.get(sumKey.toString());
			Object name = null;
			Object groupValue = m.get(groupKey.toString());
			if(dateType>0){
				name = Utils.date(Utils.parseDate(groupValue), dateFormats[dateType][1]);
			}else{
				try{
					java.lang.reflect.Method method = SrvApi.class.getMethod("get"+Utils.ForMat(groupKey.toString())+"$");
					method.setAccessible(true);
					name = method.invoke(SrvApi.fromMap(m));
				}catch(Exception ex){
					ex.printStackTrace();
				}
			}
			map.put("name", name);
			map.put("value", value);
			result.add(map);
		}
		return result;
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static int updateSrvApi(Map set,Map where){
		if(set.isEmpty())throw new RuntimeException("set为空");
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		return getSrvApiDao().updateSrvApiByConfirm(set, where);
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void deleteSrvApi(Map where){
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		getSrvApiDao().deleteSrvApiByConfirm(where);
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void delete(Long id){
		if(id==null)throw new RuntimeException("id为空");
		getSrvApiDao().removeSrvApiById(id);
	}
	
	
	/**
	 * 保存API接口对象
	 * @param params
	 * @return
	 */
	public SrvApi save(){
		if(this.getSaId()!=null)
			getSrvApiDao().updateSrvApi(this);
		else
			return getSrvApiDao().saveSrvApi(this);
		return this;
	}
	
	
	/**
	 * 更新API接口对象的非空字段,注意跟Service里面的update不一样哦
	 * @param params
	 * @return
	 */
	public int update(){
		return getSrvApiDao().updateSrvApi$NotNull(this);
	}
	
	
	/**
	 * 删除
	 * @param params
	 * @return
	 */
	public void delete(){
		if(Utils.equals(Utils.config("logic_delete"),"true"))
			getSrvApiDao().removeSrvApiById(this.getSaId());
		else
			getSrvApiDao().deleteSrvApiById(this.getSaId());
	}
	
	/**
	 * 执行事务
	 * @param function
	 */
	public static <T> T execute(Function function){
		return getSrvApiDao().executeTransaction(function);
	}
	/*******************************编号**********************************/	
	/**
	* 编号 [非空]      
	**/
	public Long getSaId(){
		if(this.saId!=null){
			return this.saId;
		}
		return this.saId;
	}
	/**
	* 获取编号格式化(toString)
	**/
	public String getSaId$(){
		String strValue="";
		 strValue=Utils.string(this.getSaId());
	 	 return strValue;
	}
	/**
	* 根据编号反格式化
	**/
	public void setSaId$(String strValue){
		if(Utils.empty(strValue)){
			this.saId=null;
			return;
		}
	 	this.saId=Utils.parseLong(strValue);
	}
	
	/**
	* 编号 [非空]      
	**/
	public void setSaId(Long saId){
		this.saId = saId;
		this.setSeted(F.saId);
	}
	
	
	
	
	/*******************************API名称**********************************/	
	/**
	* API名称 [非空]    中文描述  
	**/
	public String getSaName(){
		if(this.saName!=null){
			return this.saName;
		}
		return this.saName;
	}
	/**
	* 获取API名称格式化(toString)
	**/
	public String getSaName$(){
		String strValue="";
		 strValue=Utils.string(this.getSaName());
	 	 return strValue;
	}
	/**
	* 根据API名称反格式化
	**/
	public void setSaName$(String strValue){
		if(Utils.empty(strValue)){
			this.saName=null;
			return;
		}
	 	this.saName=strValue;
	}
	
	/**
	* API名称 [非空]    中文描述  
	**/
	public void setSaName(String saName){
		this.saName = saName;
		this.setSeted(F.saName);
	}
	
	
	
	
	/*******************************名称空间**********************************/	
	/**
	* 名称空间 [非空]    格式如:com.xxxx.xxx  
	**/
	public String getSaNamespace(){
		if(this.saNamespace!=null){
			return this.saNamespace;
		}
		return this.saNamespace;
	}
	/**
	* 获取名称空间格式化(toString)
	**/
	public String getSaNamespace$(){
		String strValue="";
		 strValue=Utils.string(this.getSaNamespace());
	 	 return strValue;
	}
	/**
	* 根据名称空间反格式化
	**/
	public void setSaNamespace$(String strValue){
		if(Utils.empty(strValue)){
			this.saNamespace=null;
			return;
		}
	 	this.saNamespace=strValue;
	}
	
	/**
	* 名称空间 [非空]    格式如:com.xxxx.xxx  
	**/
	public void setSaNamespace(String saNamespace){
		this.saNamespace = saNamespace;
		this.setSeted(F.saNamespace);
	}
	
	
	
	
	/*******************************接口分类**********************************/	
	/**
	* 接口分类 [非空] [SrvApiType]     
	**/
	public Long getSaType(){
		if(this.saType!=null){
			return this.saType;
		}
		return this.saType;
	}
	/**
	* 获取接口分类格式化(toString)
	**/
	public String getSaType$(){
		String strValue="";
		if(this.getSaType()!=null){
				strValue+=Utils.string(SrvApiType.getKeyValue(this.getSaType()));
		}			
	 	 return strValue;
	}
	/**
	* 根据接口分类反格式化
	**/
	public void setSaType$(String strValue){
		if(Utils.empty(strValue)){
			this.saType=null;
			return;
		}
		SrvApiType item = SrvApiType.find(strValue);
		if(item!=null){
			this.saType = Utils.parseLong(item.getSatId());
		}
	}
	
	/**
	* 接口分类 [非空] [SrvApiType]     
	**/
	public void setSaType(Long saType){
		this.saType = saType;
		this.setSeted(F.saType);
	}
	
	
	
	
	/**
	* 获取关联对象[API分类]
	**/	 			
 	public SrvApiType get$saType(){
 		if(this.$saType!=null)
 			return this.$saType;
 		com.distribute.framework.model.SrvApiType srvApiType = null;
		if(this.getSaType()!=null){
 			srvApiType = SrvApiType.get(this.getSaType());
 		}
 		return srvApiType;
	}
	/*******************************版本号**********************************/	
	/**
	* 版本号 [非空]   1:V1 2:V2 3:V3    
	**/
	public Short getSaVersion(){
		if(this.saVersion!=null){
			return this.saVersion;
		}
		return this.saVersion;
	}
	/**
	* 获取版本号格式化(toString)
	**/
	public String getSaVersion$(){
		String strValue="";
		 if(Utils.equals(Utils.string(this.getSaVersion()),"1"))
			strValue=Utils.string("V1");		 
		 if(Utils.equals(Utils.string(this.getSaVersion()),"2"))
			strValue=Utils.string("V2");		 
		 if(Utils.equals(Utils.string(this.getSaVersion()),"3"))
			strValue=Utils.string("V3");		 
	 	 return strValue;
	}
	/**
	* 根据版本号反格式化
	**/
	public void setSaVersion$(String strValue){
		if(Utils.empty(strValue)){
			this.saVersion=null;
			return;
		}
		 if(Utils.equals(strValue,"V1"))
		 	this.saVersion=Utils.parseShort("1");
		 if(Utils.equals(strValue,"V2"))
		 	this.saVersion=Utils.parseShort("2");
		 if(Utils.equals(strValue,"V3"))
		 	this.saVersion=Utils.parseShort("3");
	}
	
	/**
	* 版本号 [非空]   1:V1 2:V2 3:V3    
	**/
	public void setSaVersion(Short saVersion){
		this.saVersion = saVersion;
		this.setSeted(F.saVersion);
	}
	
	
	
	
	/*******************************是否开放**********************************/	
	/**
	* 是否开放 [非空]   1:开放 0:非开放    
	**/
	public Short getSaOpen(){
		if(this.saOpen!=null){
			return this.saOpen;
		}
		return this.saOpen;
	}
	/**
	* 获取是否开放格式化(toString)
	**/
	public String getSaOpen$(){
		String strValue="";
		 if(Utils.equals(Utils.string(this.getSaOpen()),"1"))
			strValue=Utils.string("开放");		 
		 if(Utils.equals(Utils.string(this.getSaOpen()),"0"))
			strValue=Utils.string("非开放");		 
	 	 return strValue;
	}
	/**
	* 根据是否开放反格式化
	**/
	public void setSaOpen$(String strValue){
		if(Utils.empty(strValue)){
			this.saOpen=null;
			return;
		}
		 if(Utils.equals(strValue,"开放"))
		 	this.saOpen=Utils.parseShort("1");
		 if(Utils.equals(strValue,"非开放"))
		 	this.saOpen=Utils.parseShort("0");
	}
	
	/**
	* 是否开放 [非空]   1:开放 0:非开放    
	**/
	public void setSaOpen(Short saOpen){
		this.saOpen = saOpen;
		this.setSeted(F.saOpen);
	}
	
	
	
	
	/*******************************需要用户授权**********************************/	
	/**
	* 需要用户授权 [非空]   0:无需授权 1:需要授权    
	**/
	public Short getSaOauth(){
		if(this.saOauth!=null){
			return this.saOauth;
		}
		return this.saOauth;
	}
	/**
	* 获取需要用户授权格式化(toString)
	**/
	public String getSaOauth$(){
		String strValue="";
		 if(Utils.equals(Utils.string(this.getSaOauth()),"0"))
			strValue=Utils.string("无需授权");		 
		 if(Utils.equals(Utils.string(this.getSaOauth()),"1"))
			strValue=Utils.string("需要授权");		 
	 	 return strValue;
	}
	/**
	* 根据需要用户授权反格式化
	**/
	public void setSaOauth$(String strValue){
		if(Utils.empty(strValue)){
			this.saOauth=null;
			return;
		}
		 if(Utils.equals(strValue,"无需授权"))
		 	this.saOauth=Utils.parseShort("0");
		 if(Utils.equals(strValue,"需要授权"))
		 	this.saOauth=Utils.parseShort("1");
	}
	
	/**
	* 需要用户授权 [非空]   0:无需授权 1:需要授权    
	**/
	public void setSaOauth(Short saOauth){
		this.saOauth = saOauth;
		this.setSeted(F.saOauth);
	}
	
	
	
	
	/*******************************接口说明**********************************/	
	/**
	* 接口说明       
	**/
	public String getSaDescript(){
		if(this.saDescript!=null){
			return this.saDescript;
		}
		return this.saDescript;
	}
	/**
	* 获取接口说明格式化(toString)
	**/
	public String getSaDescript$(){
		String strValue="";
		 strValue=Utils.string(this.getSaDescript());
	 	 return strValue;
	}
	/**
	* 根据接口说明反格式化
	**/
	public void setSaDescript$(String strValue){
		if(Utils.empty(strValue)){
			this.saDescript=null;
			return;
		}
	 	this.saDescript=strValue;
	}
	
	/**
	* 接口说明       
	**/
	public void setSaDescript(String saDescript){
		this.saDescript = saDescript;
		this.setSeted(F.saDescript);
	}
	
	
	
	
	/*******************************接口类名**********************************/	
	/**
	* 接口类名 [非空]    脚本代码为java代码,参数结构中定义的变量名可直接使用,有错误返回错误代码，没错误无需返回  
	**/
	public String getSaClass(){
		if(this.saClass!=null){
			return this.saClass;
		}
		return this.saClass;
	}
	/**
	* 获取接口类名格式化(toString)
	**/
	public String getSaClass$(){
		String strValue="";
		 strValue=Utils.string(this.getSaClass());
	 	 return strValue;
	}
	/**
	* 根据接口类名反格式化
	**/
	public void setSaClass$(String strValue){
		if(Utils.empty(strValue)){
			this.saClass=null;
			return;
		}
	 	this.saClass=strValue;
	}
	
	/**
	* 接口类名 [非空]    脚本代码为java代码,参数结构中定义的变量名可直接使用,有错误返回错误代码，没错误无需返回  
	**/
	public void setSaClass(String saClass){
		this.saClass = saClass;
		this.setSeted(F.saClass);
	}
	
	
	
	
	/*******************************数据方向**********************************/	
	/**
	* 数据方向 [非空]   0:请求 1:推送    
	**/
	public Short getSaDir(){
		if(this.saDir!=null){
			return this.saDir;
		}
		return this.saDir;
	}
	/**
	* 获取数据方向格式化(toString)
	**/
	public String getSaDir$(){
		String strValue="";
		 if(Utils.equals(Utils.string(this.getSaDir()),"0"))
			strValue=Utils.string("请求");		 
		 if(Utils.equals(Utils.string(this.getSaDir()),"1"))
			strValue=Utils.string("推送");		 
	 	 return strValue;
	}
	/**
	* 根据数据方向反格式化
	**/
	public void setSaDir$(String strValue){
		if(Utils.empty(strValue)){
			this.saDir=null;
			return;
		}
		 if(Utils.equals(strValue,"请求"))
		 	this.saDir=Utils.parseShort("0");
		 if(Utils.equals(strValue,"推送"))
		 	this.saDir=Utils.parseShort("1");
	}
	
	/**
	* 数据方向 [非空]   0:请求 1:推送    
	**/
	public void setSaDir(Short saDir){
		this.saDir = saDir;
		this.setSeted(F.saDir);
	}
	
	
	
	
	/*******************************函数名称**********************************/	
	/**
	* 函数名称 [非空]      
	**/
	public String getSaMethod(){
		if(this.saMethod!=null){
			return this.saMethod;
		}
		return this.saMethod;
	}
	/**
	* 获取函数名称格式化(toString)
	**/
	public String getSaMethod$(){
		String strValue="";
		 strValue=Utils.string(this.getSaMethod());
	 	 return strValue;
	}
	/**
	* 根据函数名称反格式化
	**/
	public void setSaMethod$(String strValue){
		if(Utils.empty(strValue)){
			this.saMethod=null;
			return;
		}
	 	this.saMethod=strValue;
	}
	
	/**
	* 函数名称 [非空]      
	**/
	public void setSaMethod(String saMethod){
		this.saMethod = saMethod;
		this.setSeted(F.saMethod);
	}
	
	
	
	
	/*******************************记录日志**********************************/	
	/**
	* 记录日志    0:否 1:是    
	**/
	public Short getSaLog(){
		if(this.saLog!=null){
			return this.saLog;
		}
		return this.saLog;
	}
	/**
	* 获取记录日志格式化(toString)
	**/
	public String getSaLog$(){
		String strValue="";
		 if(Utils.equals(Utils.string(this.getSaLog()),"0"))
			strValue=Utils.string("否");		 
		 if(Utils.equals(Utils.string(this.getSaLog()),"1"))
			strValue=Utils.string("是");		 
	 	 return strValue;
	}
	/**
	* 根据记录日志反格式化
	**/
	public void setSaLog$(String strValue){
		if(Utils.empty(strValue)){
			this.saLog=null;
			return;
		}
		 if(Utils.equals(strValue,"否"))
		 	this.saLog=Utils.parseShort("0");
		 if(Utils.equals(strValue,"是"))
		 	this.saLog=Utils.parseShort("1");
	}
	
	/**
	* 记录日志    0:否 1:是    
	**/
	public void setSaLog(Short saLog){
		this.saLog = saLog;
		this.setSeted(F.saLog);
	}
	
	
	
	
	/*******************************参数结构**********************************/	
	/**
	* 参数结构       
	**/
	public String getSaParams(){
		if(this.saParams!=null){
			return this.saParams;
		}
		return this.saParams;
	}
	/**
	* 获取参数结构格式化(toString)
	**/
	public String getSaParams$(){
		String strValue="";
		 strValue=Utils.string(this.getSaParams());
	 	 return strValue;
	}
	/**
	* 根据参数结构反格式化
	**/
	public void setSaParams$(String strValue){
		if(Utils.empty(strValue)){
			this.saParams=null;
			return;
		}
		this.saParams=strValue;
	}
	
	/**
	* 参数结构       
	**/
	public void setSaParams(String saParams){
		this.saParams = saParams;
		this.setSeted(F.saParams);
	}
	
	
	
	
	/*******************************返回结构**********************************/	
	/**
	* 返回结构 [非空]      
	**/
	public String getSaReturnStruct(){
		if(this.saReturnStruct!=null){
			return this.saReturnStruct;
		}
		return this.saReturnStruct;
	}
	/**
	* 获取返回结构格式化(toString)
	**/
	public String getSaReturnStruct$(){
		String strValue="";
		 strValue=Utils.string(this.getSaReturnStruct());
	 	 return strValue;
	}
	/**
	* 根据返回结构反格式化
	**/
	public void setSaReturnStruct$(String strValue){
		if(Utils.empty(strValue)){
			this.saReturnStruct=null;
			return;
		}
		this.saReturnStruct=strValue;
	}
	
	/**
	* 返回结构 [非空]      
	**/
	public void setSaReturnStruct(String saReturnStruct){
		this.saReturnStruct = saReturnStruct;
		this.setSeted(F.saReturnStruct);
	}
	
	
	
	
	/*******************************错误代码**********************************/	
	/**
	* 错误代码       
	**/
	public String getSaError(){
		if(this.saError!=null){
			return this.saError;
		}
		return this.saError;
	}
	/**
	* 获取错误代码格式化(toString)
	**/
	public String getSaError$(){
		String strValue="";
		 strValue=Utils.string(this.getSaError());
	 	 return strValue;
	}
	/**
	* 根据错误代码反格式化
	**/
	public void setSaError$(String strValue){
		if(Utils.empty(strValue)){
			this.saError=null;
			return;
		}
		this.saError=strValue;
	}
	
	/**
	* 错误代码       
	**/
	public void setSaError(String saError){
		this.saError = saError;
		this.setSeted(F.saError);
	}
	
	
	
	
	/*******************************修改时间**********************************/	
	/**
	* 修改时间 [非空]      
	**/
	public Date getSaUpdateTime(){
		if(this.saUpdateTime!=null){
			return this.saUpdateTime;
		}
		return this.saUpdateTime;
	}
	/**
	* 获取修改时间格式化(toString)
	**/
	public String getSaUpdateTime$(){
		String strValue="";
		 strValue=Utils.string(Utils.date(this.getSaUpdateTime(),"yyyy-MM-dd HH:mm:ss"));
	 	 return strValue;
	}
	/**
	* 根据修改时间反格式化
	**/
	public void setSaUpdateTime$(String strValue){
		if(Utils.empty(strValue)){
			this.saUpdateTime=null;
			return;
		}
	 	this.saUpdateTime=Utils.date(strValue,"yyyy-MM-dd HH:mm:ss");
	}
	
	/**
	* 修改时间 [非空]      
	**/
	public void setSaUpdateTime(Date saUpdateTime){
		this.saUpdateTime = saUpdateTime;
		this.setSeted(F.saUpdateTime);
	}
	
	
	
	
	/*******************************添加时间**********************************/	
	/**
	* 添加时间 [非空]      
	**/
	public Date getSaAddTime(){
		if(this.saAddTime!=null){
			return this.saAddTime;
		}
		return this.saAddTime;
	}
	/**
	* 获取添加时间格式化(toString)
	**/
	public String getSaAddTime$(){
		String strValue="";
		 strValue=Utils.string(Utils.date(this.getSaAddTime(),"yyyy-MM-dd HH:mm:ss"));
	 	 return strValue;
	}
	/**
	* 根据添加时间反格式化
	**/
	public void setSaAddTime$(String strValue){
		if(Utils.empty(strValue)){
			this.saAddTime=null;
			return;
		}
	 	this.saAddTime=Utils.date(strValue,"yyyy-MM-dd HH:mm:ss");
	}
	
	/**
	* 添加时间 [非空]      
	**/
	public void setSaAddTime(Date saAddTime){
		this.saAddTime = saAddTime;
		this.setSeted(F.saAddTime);
	}
	
	
	
	
	/*******************************状态**********************************/	
	/**
	* 状态 [非空]   0:测试中 1:正常 2:禁用    
	**/
	public Short getSaStatus(){
		if(this.saStatus!=null){
			return this.saStatus;
		}
		return this.saStatus;
	}
	/**
	* 获取状态格式化(toString)
	**/
	public String getSaStatus$(){
		String strValue="";
		 if(Utils.equals(Utils.string(this.getSaStatus()),"0"))
			strValue=Utils.string("测试中");		 
		 if(Utils.equals(Utils.string(this.getSaStatus()),"1"))
			strValue=Utils.string("正常");		 
		 if(Utils.equals(Utils.string(this.getSaStatus()),"2"))
			strValue=Utils.string("禁用");		 
	 	 return strValue;
	}
	/**
	* 根据状态反格式化
	**/
	public void setSaStatus$(String strValue){
		if(Utils.empty(strValue)){
			this.saStatus=null;
			return;
		}
		 if(Utils.equals(strValue,"测试中"))
		 	this.saStatus=Utils.parseShort("0");
		 if(Utils.equals(strValue,"正常"))
		 	this.saStatus=Utils.parseShort("1");
		 if(Utils.equals(strValue,"禁用"))
		 	this.saStatus=Utils.parseShort("2");
	}
	
	/**
	* 状态 [非空]   0:测试中 1:正常 2:禁用    
	**/
	public void setSaStatus(Short saStatus){
		this.saStatus = saStatus;
		this.setSeted(F.saStatus);
	}
	
	
	
	
	/************LAZY3Q_DEFINE_CODE************/
	/************LAZY3Q_DEFINE_CODE************/
	
	
	/**
	 * 触发器
	 */
	public static void on(Trigger.Index index,final Notify.Listener listener,Trigger.Type... types){
		Notify.on(SrvApi.class, index, listener, types);
	}
	public static void on(final Notify.Listener listener,String type){
		Notify.on(SrvApi.class, listener, type);
	}
	/**
	 * 当修改字段时
	 * @param filedName
	 * @param listener
	 */
	public static void on(String filedName,final Notify.Listener listener){
		Notify.on(SrvApi.class, listener, filedName);
	}
	/**
	 * 当修改字段为某值时
	 * @param filedName
	 * @param value
	 * @param listener
	 */
	public static void on(String filedName,Object value,final Notify.Listener listener){
		if(value==null)return;
		Notify.on(SrvApi.class, listener, filedName+"."+Utils.md5(""+value));
	}
	public void notify(String type){
		Trigger.on(SrvApi.class,type, this);
	}
	
	
	/**
	 * 用来获取当有字段关联对象时的获取方式,调用如${SrvApi.obj.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${SrvApi.$filedName}获取关联对象
	 */
	public Map getObj(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return SrvApi.class.getMethod("get$"+Utils.forMat(key.toString())).invoke(SrvApi.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 用来获取某字段格式化的获取方式,调用如${SrvApi.fmt.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${SrvApi.filedName$}获取某字段格式化
	 */
	public Map getFmt(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return SrvApi.class.getMethod("get"+Utils.ForMat(key.toString()+"$")).invoke(SrvApi.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 获取查询参数链式串
	 * @return
	 */
	public static @Deprecated M where(){ return new M(0); }
	public static @Deprecated M m(){ return new M(0); }
	public static M where = new M(0,true);
	public static @database(DatabaseNames.distribute_sys) class M extends IbatisMap{
		int type = 0; 
		M linked = null;
		Boolean proxy = false;
		public M set = null;
		public M(int type){
			this.type = type;
			if(this.type==0){
				set = new M(1,true);
				set.linked = this;
			}
		};
		public M(int type,Boolean proxy){
			this.type = type;
			this.proxy=proxy;
		};
		public M proxy(){
			M m = new M(this.type);//当前的对像
			if(this.type==0){
				m.set = new M(1,true);//set对象
				m.set.linked = m;
			}else{
				m.linked=this.linked;
				this.linked.linked=m;
			}
			return m;
		}
		public @Deprecated M set(){			
			M m = this;
			m.linked=new M(1);
			m.linked.linked=m;
			return m.linked;
		};
		public M on(IbatisMap value,C column,String joinColumn){if(proxy)return proxy().on(value,column,joinColumn);this.put(value.getClass().getDeclaringClass().getSimpleName(), value);value.put("on", column.toString());value.put("to", joinColumn);return this;};
		/** 编号 [非空]       **/
		public M saId(Object saId){if(proxy)return proxy().saId(saId);  this.put("saId", saId);return this;};
	 	/** and sa_id is null */
 		public M saIdNull(){if(proxy)return proxy().saIdNull();if(this.get("saIdNot")==null)this.put("saIdNot", "");this.put("saId", null);return this;};
 		/** not .... */
 		public M saIdNot(){if(proxy)return proxy().saIdNot();this.put("saIdNot", "not");return this;};
 		public M saIdNotNull(){if(proxy)return proxy().saIdNotNull();this.put("saIdNot", "not");this.put("saId", null);return this;};
 		public M saIdNot(Object saId){if(proxy)return proxy().saIdNot(saId);this.put("saIdNot", "not");this.put("saId", saId);return this;};
		/** and sa_id <= ? */
		public M saIdMin(Object min){if(proxy)return proxy().saIdMin(min);this.put("saIdMin", min);return this;};
		/** and sa_id >= ? */
		public M saIdMax(Object max){if(proxy)return proxy().saIdMax(max);this.put("saIdMax", max);return this;};
		public M saIdIn(String ids){
			if(proxy)return proxy().saIdIn(ids);  this.put("saIdIn", ids);return this;
		};	
		/** API名称 [非空]    中文描述   **/
		public M saName(Object saName){if(proxy)return proxy().saName(saName);  this.put("saName", saName);return this;};
	 	/** and sa_name is null */
 		public M saNameNull(){if(proxy)return proxy().saNameNull();if(this.get("saNameNot")==null)this.put("saNameNot", "");this.put("saName", null);return this;};
 		/** not .... */
 		public M saNameNot(){if(proxy)return proxy().saNameNot();this.put("saNameNot", "not");return this;};
 		public M saNameNotNull(){if(proxy)return proxy().saNameNotNull();this.put("saNameNot", "not");this.put("saName", null);return this;};
 		public M saNameNot(Object saName){if(proxy)return proxy().saNameNot(saName);this.put("saNameNot", "not");this.put("saName", saName);return this;};
		/** 名称空间 [非空]    格式如:com.xxxx.xxx   **/
		public M saNamespace(Object saNamespace){if(proxy)return proxy().saNamespace(saNamespace);  this.put("saNamespace", saNamespace);return this;};
	 	/** and sa_namespace is null */
 		public M saNamespaceNull(){if(proxy)return proxy().saNamespaceNull();if(this.get("saNamespaceNot")==null)this.put("saNamespaceNot", "");this.put("saNamespace", null);return this;};
 		/** not .... */
 		public M saNamespaceNot(){if(proxy)return proxy().saNamespaceNot();this.put("saNamespaceNot", "not");return this;};
 		public M saNamespaceNotNull(){if(proxy)return proxy().saNamespaceNotNull();this.put("saNamespaceNot", "not");this.put("saNamespace", null);return this;};
 		public M saNamespaceNot(Object saNamespace){if(proxy)return proxy().saNamespaceNot(saNamespace);this.put("saNamespaceNot", "not");this.put("saNamespace", saNamespace);return this;};
		public M saType$on(SrvApiType.M value){if(proxy)return proxy().saType$on(value);this.put("SaType", value);value.put("on", "sa_type");return this;};
		/** 接口分类 [非空] [SrvApiType]      **/
		public M saType(Object saType){if(proxy)return proxy().saType(saType);  this.put("saType", saType);return this;};
	 	/** and sa_type is null */
 		public M saTypeNull(){if(proxy)return proxy().saTypeNull();if(this.get("saTypeNot")==null)this.put("saTypeNot", "");this.put("saType", null);return this;};
 		/** not .... */
 		public M saTypeNot(){if(proxy)return proxy().saTypeNot();this.put("saTypeNot", "not");return this;};
 		public M saTypeNotNull(){if(proxy)return proxy().saTypeNotNull();this.put("saTypeNot", "not");this.put("saType", null);return this;};
 		public M saTypeNot(Object saType){if(proxy)return proxy().saTypeNot(saType);this.put("saTypeNot", "not");this.put("saType", saType);return this;};
		public M saTypeIn(String ids){
			if(proxy)return proxy().saTypeIn(ids);  this.put("saTypeIn", ids);return this;
		};	
		/** 版本号 [非空]   1:V1 2:V2 3:V3     **/
		public M saVersion(Object saVersion){if(proxy)return proxy().saVersion(saVersion);  this.put("saVersion", saVersion);return this;};
	 	/** and sa_version is null */
 		public M saVersionNull(){if(proxy)return proxy().saVersionNull();if(this.get("saVersionNot")==null)this.put("saVersionNot", "");this.put("saVersion", null);return this;};
 		/** not .... */
 		public M saVersionNot(){if(proxy)return proxy().saVersionNot();this.put("saVersionNot", "not");return this;};
 		public M saVersionNotNull(){if(proxy)return proxy().saVersionNotNull();this.put("saVersionNot", "not");this.put("saVersion", null);return this;};
 		public M saVersionNot(Object saVersion){if(proxy)return proxy().saVersionNot(saVersion);this.put("saVersionNot", "not");this.put("saVersion", saVersion);return this;};
		public M saVersionIn(String ids){
			if(proxy)return proxy().saVersionIn(ids);  this.put("saVersionIn", ids);return this;
		};	
		/** 是否开放 [非空]   1:开放 0:非开放     **/
		public M saOpen(Object saOpen){if(proxy)return proxy().saOpen(saOpen);  this.put("saOpen", saOpen);return this;};
	 	/** and sa_open is null */
 		public M saOpenNull(){if(proxy)return proxy().saOpenNull();if(this.get("saOpenNot")==null)this.put("saOpenNot", "");this.put("saOpen", null);return this;};
 		/** not .... */
 		public M saOpenNot(){if(proxy)return proxy().saOpenNot();this.put("saOpenNot", "not");return this;};
 		public M saOpenNotNull(){if(proxy)return proxy().saOpenNotNull();this.put("saOpenNot", "not");this.put("saOpen", null);return this;};
 		public M saOpenNot(Object saOpen){if(proxy)return proxy().saOpenNot(saOpen);this.put("saOpenNot", "not");this.put("saOpen", saOpen);return this;};
		public M saOpenIn(String ids){
			if(proxy)return proxy().saOpenIn(ids);  this.put("saOpenIn", ids);return this;
		};	
		/** 需要用户授权 [非空]   0:无需授权 1:需要授权     **/
		public M saOauth(Object saOauth){if(proxy)return proxy().saOauth(saOauth);  this.put("saOauth", saOauth);return this;};
	 	/** and sa_oauth is null */
 		public M saOauthNull(){if(proxy)return proxy().saOauthNull();if(this.get("saOauthNot")==null)this.put("saOauthNot", "");this.put("saOauth", null);return this;};
 		/** not .... */
 		public M saOauthNot(){if(proxy)return proxy().saOauthNot();this.put("saOauthNot", "not");return this;};
 		public M saOauthNotNull(){if(proxy)return proxy().saOauthNotNull();this.put("saOauthNot", "not");this.put("saOauth", null);return this;};
 		public M saOauthNot(Object saOauth){if(proxy)return proxy().saOauthNot(saOauth);this.put("saOauthNot", "not");this.put("saOauth", saOauth);return this;};
		public M saOauthIn(String ids){
			if(proxy)return proxy().saOauthIn(ids);  this.put("saOauthIn", ids);return this;
		};	
		/** 接口说明        **/
		public M saDescript(Object saDescript){if(proxy)return proxy().saDescript(saDescript);  this.put("saDescript", saDescript);return this;};
	 	/** and sa_descript is null */
 		public M saDescriptNull(){if(proxy)return proxy().saDescriptNull();if(this.get("saDescriptNot")==null)this.put("saDescriptNot", "");this.put("saDescript", null);return this;};
 		/** not .... */
 		public M saDescriptNot(){if(proxy)return proxy().saDescriptNot();this.put("saDescriptNot", "not");return this;};
 		public M saDescriptNotNull(){if(proxy)return proxy().saDescriptNotNull();this.put("saDescriptNot", "not");this.put("saDescript", null);return this;};
 		public M saDescriptNot(Object saDescript){if(proxy)return proxy().saDescriptNot(saDescript);this.put("saDescriptNot", "not");this.put("saDescript", saDescript);return this;};
		/** 接口类名 [非空]    脚本代码为java代码,参数结构中定义的变量名可直接使用,有错误返回错误代码，没错误无需返回   **/
		public M saClass(Object saClass){if(proxy)return proxy().saClass(saClass);  this.put("saClass", saClass);return this;};
	 	/** and sa_class is null */
 		public M saClassNull(){if(proxy)return proxy().saClassNull();if(this.get("saClassNot")==null)this.put("saClassNot", "");this.put("saClass", null);return this;};
 		/** not .... */
 		public M saClassNot(){if(proxy)return proxy().saClassNot();this.put("saClassNot", "not");return this;};
 		public M saClassNotNull(){if(proxy)return proxy().saClassNotNull();this.put("saClassNot", "not");this.put("saClass", null);return this;};
 		public M saClassNot(Object saClass){if(proxy)return proxy().saClassNot(saClass);this.put("saClassNot", "not");this.put("saClass", saClass);return this;};
		/** 数据方向 [非空]   0:请求 1:推送     **/
		public M saDir(Object saDir){if(proxy)return proxy().saDir(saDir);  this.put("saDir", saDir);return this;};
	 	/** and sa_dir is null */
 		public M saDirNull(){if(proxy)return proxy().saDirNull();if(this.get("saDirNot")==null)this.put("saDirNot", "");this.put("saDir", null);return this;};
 		/** not .... */
 		public M saDirNot(){if(proxy)return proxy().saDirNot();this.put("saDirNot", "not");return this;};
 		public M saDirNotNull(){if(proxy)return proxy().saDirNotNull();this.put("saDirNot", "not");this.put("saDir", null);return this;};
 		public M saDirNot(Object saDir){if(proxy)return proxy().saDirNot(saDir);this.put("saDirNot", "not");this.put("saDir", saDir);return this;};
		public M saDirIn(String ids){
			if(proxy)return proxy().saDirIn(ids);  this.put("saDirIn", ids);return this;
		};	
		/** 函数名称 [非空]       **/
		public M saMethod(Object saMethod){if(proxy)return proxy().saMethod(saMethod);  this.put("saMethod", saMethod);return this;};
	 	/** and sa_method is null */
 		public M saMethodNull(){if(proxy)return proxy().saMethodNull();if(this.get("saMethodNot")==null)this.put("saMethodNot", "");this.put("saMethod", null);return this;};
 		/** not .... */
 		public M saMethodNot(){if(proxy)return proxy().saMethodNot();this.put("saMethodNot", "not");return this;};
 		public M saMethodNotNull(){if(proxy)return proxy().saMethodNotNull();this.put("saMethodNot", "not");this.put("saMethod", null);return this;};
 		public M saMethodNot(Object saMethod){if(proxy)return proxy().saMethodNot(saMethod);this.put("saMethodNot", "not");this.put("saMethod", saMethod);return this;};
		/** 记录日志    0:否 1:是     **/
		public M saLog(Object saLog){if(proxy)return proxy().saLog(saLog);  this.put("saLog", saLog);return this;};
	 	/** and sa_log is null */
 		public M saLogNull(){if(proxy)return proxy().saLogNull();if(this.get("saLogNot")==null)this.put("saLogNot", "");this.put("saLog", null);return this;};
 		/** not .... */
 		public M saLogNot(){if(proxy)return proxy().saLogNot();this.put("saLogNot", "not");return this;};
 		public M saLogNotNull(){if(proxy)return proxy().saLogNotNull();this.put("saLogNot", "not");this.put("saLog", null);return this;};
 		public M saLogNot(Object saLog){if(proxy)return proxy().saLogNot(saLog);this.put("saLogNot", "not");this.put("saLog", saLog);return this;};
		public M saLogIn(String ids){
			if(proxy)return proxy().saLogIn(ids);  this.put("saLogIn", ids);return this;
		};	
		/** 参数结构        **/
		public M saParams(Object saParams){if(proxy)return proxy().saParams(saParams);  this.put("saParams", saParams);return this;};
	 	/** and sa_params is null */
 		public M saParamsNull(){if(proxy)return proxy().saParamsNull();if(this.get("saParamsNot")==null)this.put("saParamsNot", "");this.put("saParams", null);return this;};
 		/** not .... */
 		public M saParamsNot(){if(proxy)return proxy().saParamsNot();this.put("saParamsNot", "not");return this;};
 		public M saParamsNotNull(){if(proxy)return proxy().saParamsNotNull();this.put("saParamsNot", "not");this.put("saParams", null);return this;};
 		public M saParamsNot(Object saParams){if(proxy)return proxy().saParamsNot(saParams);this.put("saParamsNot", "not");this.put("saParams", saParams);return this;};
		/** 返回结构 [非空]       **/
		public M saReturnStruct(Object saReturnStruct){if(proxy)return proxy().saReturnStruct(saReturnStruct);  this.put("saReturnStruct", saReturnStruct);return this;};
	 	/** and sa_return_struct is null */
 		public M saReturnStructNull(){if(proxy)return proxy().saReturnStructNull();if(this.get("saReturnStructNot")==null)this.put("saReturnStructNot", "");this.put("saReturnStruct", null);return this;};
 		/** not .... */
 		public M saReturnStructNot(){if(proxy)return proxy().saReturnStructNot();this.put("saReturnStructNot", "not");return this;};
 		public M saReturnStructNotNull(){if(proxy)return proxy().saReturnStructNotNull();this.put("saReturnStructNot", "not");this.put("saReturnStruct", null);return this;};
 		public M saReturnStructNot(Object saReturnStruct){if(proxy)return proxy().saReturnStructNot(saReturnStruct);this.put("saReturnStructNot", "not");this.put("saReturnStruct", saReturnStruct);return this;};
		/** 错误代码        **/
		public M saError(Object saError){if(proxy)return proxy().saError(saError);  this.put("saError", saError);return this;};
	 	/** and sa_error is null */
 		public M saErrorNull(){if(proxy)return proxy().saErrorNull();if(this.get("saErrorNot")==null)this.put("saErrorNot", "");this.put("saError", null);return this;};
 		/** not .... */
 		public M saErrorNot(){if(proxy)return proxy().saErrorNot();this.put("saErrorNot", "not");return this;};
 		public M saErrorNotNull(){if(proxy)return proxy().saErrorNotNull();this.put("saErrorNot", "not");this.put("saError", null);return this;};
 		public M saErrorNot(Object saError){if(proxy)return proxy().saErrorNot(saError);this.put("saErrorNot", "not");this.put("saError", saError);return this;};
		/** 修改时间 [非空]       **/
		public M saUpdateTime(Object saUpdateTime){if(proxy)return proxy().saUpdateTime(saUpdateTime);  this.put("saUpdateTime", saUpdateTime);return this;};
	 	/** and sa_update_time is null */
 		public M saUpdateTimeNull(){if(proxy)return proxy().saUpdateTimeNull();if(this.get("saUpdateTimeNot")==null)this.put("saUpdateTimeNot", "");this.put("saUpdateTime", null);return this;};
 		/** not .... */
 		public M saUpdateTimeNot(){if(proxy)return proxy().saUpdateTimeNot();this.put("saUpdateTimeNot", "not");return this;};
 		public M saUpdateTimeNotNull(){if(proxy)return proxy().saUpdateTimeNotNull();this.put("saUpdateTimeNot", "not");this.put("saUpdateTime", null);return this;};
 		public M saUpdateTimeNot(Object saUpdateTime){if(proxy)return proxy().saUpdateTimeNot(saUpdateTime);this.put("saUpdateTimeNot", "not");this.put("saUpdateTime", saUpdateTime);return this;};
 		/** and sa_update_time >= ? */
 		public M saUpdateTimeStart(Object start){if(proxy)return proxy().saUpdateTimeStart(start);this.put("saUpdateTimeStart", start);return this;};			
 		/** and sa_update_time <= ? */
 		public M saUpdateTimeEnd(Object end){if(proxy)return proxy().saUpdateTimeEnd(end);this.put("saUpdateTimeEnd", end);return this;};
		/** 添加时间 [非空]       **/
		public M saAddTime(Object saAddTime){if(proxy)return proxy().saAddTime(saAddTime);  this.put("saAddTime", saAddTime);return this;};
	 	/** and sa_add_time is null */
 		public M saAddTimeNull(){if(proxy)return proxy().saAddTimeNull();if(this.get("saAddTimeNot")==null)this.put("saAddTimeNot", "");this.put("saAddTime", null);return this;};
 		/** not .... */
 		public M saAddTimeNot(){if(proxy)return proxy().saAddTimeNot();this.put("saAddTimeNot", "not");return this;};
 		public M saAddTimeNotNull(){if(proxy)return proxy().saAddTimeNotNull();this.put("saAddTimeNot", "not");this.put("saAddTime", null);return this;};
 		public M saAddTimeNot(Object saAddTime){if(proxy)return proxy().saAddTimeNot(saAddTime);this.put("saAddTimeNot", "not");this.put("saAddTime", saAddTime);return this;};
 		/** and sa_add_time >= ? */
 		public M saAddTimeStart(Object start){if(proxy)return proxy().saAddTimeStart(start);this.put("saAddTimeStart", start);return this;};			
 		/** and sa_add_time <= ? */
 		public M saAddTimeEnd(Object end){if(proxy)return proxy().saAddTimeEnd(end);this.put("saAddTimeEnd", end);return this;};
		/** 状态 [非空]   0:测试中 1:正常 2:禁用     **/
		public M saStatus(Object saStatus){if(proxy)return proxy().saStatus(saStatus);  this.put("saStatus", saStatus);return this;};
	 	/** and sa_status is null */
 		public M saStatusNull(){if(proxy)return proxy().saStatusNull();if(this.get("saStatusNot")==null)this.put("saStatusNot", "");this.put("saStatus", null);return this;};
 		/** not .... */
 		public M saStatusNot(){if(proxy)return proxy().saStatusNot();this.put("saStatusNot", "not");return this;};
 		public M saStatusNotNull(){if(proxy)return proxy().saStatusNotNull();this.put("saStatusNot", "not");this.put("saStatus", null);return this;};
 		public M saStatusNot(Object saStatus){if(proxy)return proxy().saStatusNot(saStatus);this.put("saStatusNot", "not");this.put("saStatus", saStatus);return this;};
		public M saStatusIn(String ids){
			if(proxy)return proxy().saStatusIn(ids);  this.put("saStatusIn", ids);return this;
		};	
	 	public M add(String key, Object value) {if(proxy)return proxy().add(key,value);this.put(key, value);return this;}
	 	public M add(F key, Object value) {if(proxy)return proxy().add(key,value);this.put(key.toString(), value);return this;}
	 	public M desc(C key) {if(proxy)return proxy().desc(key);this.put("desc", key.column);return this;}
	 	public M asc(C key) {if(proxy)return proxy().asc(key);this.put("asc", key.column);return this;}
	 	public M desc(String sql) {if(proxy)return proxy().desc(sql);this.put("desc", sql);return this;}
	 	public M asc(String sql) {if(proxy)return proxy().asc(sql);this.put("asc", sql);return this;}
	 	public M definex(String sql) {if(proxy)return proxy().definex(sql);this.put("definex", sql);return this;}
	 	/** 获取所有API接口 **/
		public @api List<SrvApi> list(Integer size){			
			return getSrvApiList(this,size);
		}
		/** 获取API接口分页 **/
		public @api Page<SrvApi> page(Integer page,Integer size){			
			return getSrvApiPage(page, size , this);
		}
		/** 根据查询条件取API接口 **/
		public @api SrvApi get(){			
			return getSrvApi(this);
		}
		/** 获取API接口数 **/
		public @api Long count(){			
			return getSrvApiCount(this);
		}
		/** 获取API接口表达式 **/
		public @api <T> T eval(String strEval){			
			return getSrvApiEval(strEval,this);
		}
		/** 获取API接口统计 **/
		public @api List<Map> stats(C sumKey,C groupKey,int dateType){			
			return getSrvApiStats(this,sumKey,groupKey,dateType);
		}
		/** 获取API接口统计 **/
		public @api List<Map> stats(C sumKey,C groupKey){			
			return getSrvApiStats(this,sumKey,groupKey,-1);
		}
		/** 根据条件更新 **/
		public @api int update(){			
			M where = null;
			M set = null;
			if(this.type==0){
				if(this.linked==null)throw new RuntimeException("未发set");
				where = this;
				set = this.linked;
			}else{
				if(this.linked==null)throw new RuntimeException("未发where条件");
				set = this;
				where = this.linked;
			}
			return updateSrvApi(set,where);
		}
		/** 根据条件删除 **/
		public @api void delete(){			
			deleteSrvApi(this);
		}
	}
	
	public static class Param extends M{
		public Param(int type) {
			super(type);
		}
		public Param(int type, Boolean proxy) {
			super(type, proxy);
		}
	}
	
	/** 对象的字段描述 **/
	public static class F{
		/** 编号 [非空]       **/
		public final static @type(Long.class)  String saId="saId";
		/** API名称 [非空]    中文描述   **/
		public final static @type(String.class)  String saName="saName";
		/** 名称空间 [非空]    格式如:com.xxxx.xxx   **/
		public final static @type(String.class)  String saNamespace="saNamespace";
		/** 接口分类 [非空] [SrvApiType]      **/
		public final static @type(Long.class)  String saType="saType";
		/** 版本号 [非空]   1:V1 2:V2 3:V3     **/
		public final static @type(Short.class)  String saVersion="saVersion";
		/** 是否开放 [非空]   1:开放 0:非开放     **/
		public final static @type(Short.class)  String saOpen="saOpen";
		/** 需要用户授权 [非空]   0:无需授权 1:需要授权     **/
		public final static @type(Short.class)  String saOauth="saOauth";
		/** 接口说明        **/
		public final static @type(String.class)  String saDescript="saDescript";
		/** 接口类名 [非空]    脚本代码为java代码,参数结构中定义的变量名可直接使用,有错误返回错误代码，没错误无需返回   **/
		public final static @type(String.class) @like String saClass="saClass";
		/** 数据方向 [非空]   0:请求 1:推送     **/
		public final static @type(Short.class)  String saDir="saDir";
		/** 函数名称 [非空]       **/
		public final static @type(String.class)  String saMethod="saMethod";
		/** 记录日志    0:否 1:是     **/
		public final static @type(Short.class)  String saLog="saLog";
		/** 参数结构        **/
		public final static @type(String.class) @like String saParams="saParams";
		/** 返回结构 [非空]       **/
		public final static @type(String.class) @like String saReturnStruct="saReturnStruct";
		/** 错误代码        **/
		public final static @type(String.class) @like String saError="saError";
		/** 修改时间 [非空]       **/
		public final static @type(Date.class)  String saUpdateTime="saUpdateTime";
	 	/** and sa_update_time >= ? */
 		public final static @type(Date.class) String saUpdateTimeStart="saUpdateTimeStart";
 		/** and sa_update_time <= ? */
 		public final static @type(Date.class) String saUpdateTimeEnd="saUpdateTimeEnd";
		/** 添加时间 [非空]       **/
		public final static @type(Date.class)  String saAddTime="saAddTime";
	 	/** and sa_add_time >= ? */
 		public final static @type(Date.class) String saAddTimeStart="saAddTimeStart";
 		/** and sa_add_time <= ? */
 		public final static @type(Date.class) String saAddTimeEnd="saAddTimeEnd";
		/** 状态 [非空]   0:测试中 1:正常 2:禁用     **/
		public final static @type(Short.class)  String saStatus="saStatus";
	 	public static String get(String name){
			try {
				Field field = F.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	/** 对象的数据库字段描述 **/
	public static enum C{
		saId("sa_id"),
		saName("sa_name"),
		saNamespace("sa_namespace"),
		saType("sa_type"),
		saVersion("sa_version"),
		saOpen("sa_open"),
		saOauth("sa_oauth"),
		saDescript("sa_descript"),
		saClass("sa_class"),
		saDir("sa_dir"),
		saMethod("sa_method"),
		saLog("sa_log"),
		saParams("sa_params"),
		saReturnStruct("sa_return_struct"),
		saError("sa_error"),
		saUpdateTime("sa_update_time"),
		saAddTime("sa_add_time"),
		saStatus("sa_status"),
		count("count");
		String column;
		C(String column){
			this.column = column;
		}
		public String toString(){
			return this.column;
		}
		public static String get(String name){
			try {
				Field field = C.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	/**
	* 获取API接口数据
	**/
	public static Object getData(Object param){
		if(param==null)
			return null;
		Object value = null;
		if(param.getClass()==Long.class)
			value = SrvApi.get((Long)param);
		else if(param instanceof java.util.Map){
			java.util.Map params = (Map) param;
			if(params.get("size")==null)
				value = SrvApi.getSrvApi(params);
			else
				value = SrvApi.getSrvApiList(params, (Integer) params.get("size"));
		}else if(param.getClass()==Long.class )
			value =  SrvApi.where().saId(param).get();
		else if(!Utils.empty(param.toString()))
			value = SrvApi.get(Long.valueOf(param.toString()));
		return value;
	}
	
	/**对象转json**/
	public Map toJSON(){
		return toJSON(false);
	}
	public Map toJSON(boolean simple){
		Map map = new HashMap();
		map.put("id",this.getSaId());
		Utils.fms(map,simple?"id":"saId",this.getSaId(),this.getSaId$());
		Utils.fms(map,simple?"name":"saName",this.getSaName(),this.getSaName$());
		Utils.fms(map,simple?"namespace":"saNamespace",this.getSaNamespace(),this.getSaNamespace$());
		Utils.fms(map,simple?"type":"saType",this.getSaType(),this.getSaType$());
		Utils.fms(map,simple?"version":"saVersion",this.getSaVersion(),this.getSaVersion$());
		Utils.fms(map,simple?"open":"saOpen",this.getSaOpen(),this.getSaOpen$());
		Utils.fms(map,simple?"oauth":"saOauth",this.getSaOauth(),this.getSaOauth$());
		Utils.fms(map,simple?"descript":"saDescript",this.getSaDescript(),this.getSaDescript$());
		Utils.fms(map,simple?"class":"saClass",this.getSaClass(),this.getSaClass$());
		Utils.fms(map,simple?"dir":"saDir",this.getSaDir(),this.getSaDir$());
		Utils.fms(map,simple?"method":"saMethod",this.getSaMethod(),this.getSaMethod$());
		Utils.fms(map,simple?"log":"saLog",this.getSaLog(),this.getSaLog$());
		Utils.fms(map,simple?"params":"saParams",this.getSaParams(),this.getSaParams$());
		Utils.fms(map,simple?"returnStruct":"saReturnStruct",this.getSaReturnStruct(),this.getSaReturnStruct$());
		Utils.fms(map,simple?"error":"saError",this.getSaError(),this.getSaError$());
		Utils.fms(map,simple?"updateTime":"saUpdateTime",this.getSaUpdateTime(),this.getSaUpdateTime$());
		Utils.fms(map,simple?"addTime":"saAddTime",this.getSaAddTime(),this.getSaAddTime$());
		Utils.fms(map,simple?"status":"saStatus",this.getSaStatus(),this.getSaStatus$());
		if(this.suffix!=null)map.put("suffix", this.suffix);
		/************LAZY3Q_DEFINE_TOJSON************/
		/************LAZY3Q_DEFINE_TOJSON************/
		return map;
	}
	/**对象转map**/
	public Map toMap(){
		Map map = new HashMap();
		map.put("saId",this.getSaId());
		map.put("saName",this.getSaName());
		map.put("saNamespace",this.getSaNamespace());
		map.put("saType",this.getSaType());
		map.put("saVersion",this.getSaVersion());
		map.put("saOpen",this.getSaOpen());
		map.put("saOauth",this.getSaOauth());
		map.put("saDescript",this.getSaDescript());
		map.put("saClass",this.getSaClass());
		map.put("saDir",this.getSaDir());
		map.put("saMethod",this.getSaMethod());
		map.put("saLog",this.getSaLog());
		map.put("saParams",this.getSaParams());
		map.put("saReturnStruct",this.getSaReturnStruct());
		map.put("saError",this.getSaError());
		map.put("saUpdateTime",this.getSaUpdateTime());
		map.put("saAddTime",this.getSaAddTime());
		map.put("saStatus",this.getSaStatus());
		map.put("suffix", this.suffix);
		/************LAZY3Q_DEFINE_TOMAP************/
		/************LAZY3Q_DEFINE_TOMAP************/
		return map;
	}
	/**map转对象**/
	public static SrvApi fromMap(Map map){
		SrvApi srvApi = new SrvApi();
		srvApi.saId = Utils.parseLong(map.get("saId"));
		srvApi.saName = Utils.parseString(map.get("saName"));
		srvApi.saNamespace = Utils.parseString(map.get("saNamespace"));
		srvApi.saType = Utils.parseLong(map.get("saType"));
		srvApi.saVersion = Utils.parseShort(map.get("saVersion"));
		srvApi.saOpen = Utils.parseShort(map.get("saOpen"));
		srvApi.saOauth = Utils.parseShort(map.get("saOauth"));
		srvApi.saDescript = Utils.parseString(map.get("saDescript"));
		srvApi.saClass = Utils.parseString(map.get("saClass"));
		srvApi.saDir = Utils.parseShort(map.get("saDir"));
		srvApi.saMethod = Utils.parseString(map.get("saMethod"));
		srvApi.saLog = Utils.parseShort(map.get("saLog"));
		srvApi.saParams = Utils.parseString(map.get("saParams"));
		srvApi.saReturnStruct = Utils.parseString(map.get("saReturnStruct"));
		srvApi.saError = Utils.parseString(map.get("saError"));
		srvApi.saUpdateTime = Utils.parseDate(map.get("saUpdateTime"));
		srvApi.saAddTime = Utils.parseDate(map.get("saAddTime"));
		srvApi.saStatus = Utils.parseShort(map.get("saStatus"));
		return srvApi;
	}
	
	
	
	/**字段设置标记队列**/
	private Map<String,Boolean> seted=new HashMap();
	public Boolean getSeted(String key){
		return seted.get(key);
	}
	public void setSeted(String key){
		seted.put(key,true);
	}
	/**同步未set的字段**/
	public void mergeSet(SrvApi old){
		Field[] fields = this.getClass().getDeclaredFields();
		try {
			for(Field field:fields){
				String key = field.getName();
				if(seted.get(key)==null && field.getAnnotation(column.class)!=null){
					field.setAccessible(true);
					field.set(this, field.get(old));					
				}
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
		
	/**自定义变量存储**/
	private Map values=new HashMap();
	public Map getValues(){
		return values;
	}
	public void setValues(String name,Object value){
		values.put(name,value);
	}
	
	/**分表时的表名后缀**/
	private String suffix;
	public String getSuffix() {
		return suffix;
	}
	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}
	/**获取数据库名称**/
	public static String getDataBaseName(){
		return Utils.config("spring.datasource.distribute_sys.name");
	}
	
	public static String getIcon(){
		return "/images/icons/2008825642250778015.png";
	}
	public static String getIconfont(){
		return "icon-gongzuotai";
	}
	public static enum ACT{
		列表,添加,修改,详情
	};
	public static String getUrl(ACT act,SrvApi.M params){
		if(params==null)params=new SrvApi.M(0);
		params.remove("joins");
		params.remove("definexs");
		params.remove("distinct");
		String strUrl = "/admin/api/api.edit.html?";
		if(params.get("saId")!=null){
			strUrl+="&id="+Utils.encode(""+params.get("saId"),Utils.UTF8);
		}
		if(act==ACT.列表){
			strUrl = "/admin/api/api.html?1=1";
		}else if(act==ACT.添加){
			strUrl+="&edittype=insert";
		}else if(act==ACT.修改){
			strUrl+="&edittype=update";
		}else if(act==ACT.详情){
			strUrl+="&edittype=detail";
		}		
		if(params!=null){
			for(Object key:params.keySet()){
				strUrl+="&"+key+"="+Utils.encode(""+params.get(key),Utils.UTF8)+"";
			}
		}
		return strUrl;
	}
	public String getDetailUrl(){
		return this.getUrl(ACT.详情, where.saId(this.getId()));
	}
	
	/**
	* 转跳到当前地址
	**/
	public static Protocol redirect(SrvApi.ACT act,SrvApi.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_REDIRECT");
		protocol.set("url",SrvApi.getUrl(act, params));
		return protocol;
	}
	/**
	* 打开一个新的tab页面
	**/
	public static Protocol href(SrvApi.ACT act,SrvApi.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_HREF");
		protocol.set("url",SrvApi.getUrl(act, params));
		protocol.set("title",act.name());
		return protocol;
	}
	/**
	* 显示一个消息框，并且关闭当前的对话框
	**/
	public static Protocol message(String message){
		Protocol protocol = Protocol.create(true,null,"ACT_MESSAGE");
		protocol.set("message",message);
		return protocol;
	}
	
	
	static com.distribute.framework.dao.ISrvApiDao getSrvApiDao(){
		return Utils.getBean("srvApiDao");
	};
	
}